Total Complexity | 2 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { |
||
18 | |||
19 | @Controller('app/faircalendar/events/delete') |
||
20 | @UseGuards(IsAuthenticatedGuard) |
||
21 | export class DeleteEventController { |
||
22 | constructor( |
||
23 | @Inject('ICommandBus') |
||
24 | private readonly commandBus: ICommandBus |
||
25 | ) {} |
||
26 | |||
27 | @Post(':id') |
||
28 | @WithName('faircalendar_event_delete') |
||
29 | public async post( |
||
30 | @Param() dto: IdDTO, |
||
31 | @LoggedUser() user: User, |
||
32 | @Res() res: Response |
||
33 | ) { |
||
34 | try { |
||
35 | await this.commandBus.execute(new DeleteEventCommand(dto.id, user)); |
||
36 | res.redirect(303, '/app/faircalendar'); |
||
37 | } catch (e) { |
||
38 | throw new BadRequestException(e.message); |
||
39 | } |
||
42 |